package com.oigx.lookmu.core;

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.util.xmlb.XmlSerializerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;


@State(
        name = "com.zhjw.water_reader.service.AppSettingsState",
        storages = @Storage("look_mu.xml")
)
public class SettingsState implements PersistentStateComponent<SettingsState> {

    /**
     * 文件路径
     */
    public String filePath = "";
    /**
     * 每行最大字数
     */
    public Integer lineMaxChar = 60;

    /**
     * 选中的文件下标
     */
    public int fileIndex = 0;
    /**
     * 选中章节下标
     */
    public int chapterIndex = 0;

    /**
     * 当前阅读行
     */
    public int readLine = 0;

    public List<TxtBook> bookList;

    public List<TxtChapter> chapterList;

    public List<String> readLineList;

    public static SettingsState getInstance() {
        return ApplicationManager.getApplication().getService(SettingsState.class);
    }

    @Override
    public @Nullable SettingsState getState() {
        return this;
    }

    @Override
    public void loadState(@NotNull SettingsState state) {
        XmlSerializerUtil.copyBean(state, this);
    }


}
